package com.vibration.web.controller.baseinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vibration.common.annotation.Log;
import com.vibration.common.core.controller.BaseController;
import com.vibration.common.core.domain.AjaxResult;
import com.vibration.common.enums.BusinessType;
import com.vibration.baseinfo.domain.CzTemperatureCorrect;
import com.vibration.baseinfo.service.ICzTemperatureCorrectService;
import com.vibration.common.utils.poi.ExcelUtil;
import com.vibration.common.core.page.TableDataInfo;

/**
 * 温度矫正系数Controller
 * 
 * @author wuyuhua
 * @date 2023-04-19
 */
@RestController
@RequestMapping("/baseinfo/correct")
public class CzTemperatureCorrectController extends BaseController
{
    @Autowired
    private ICzTemperatureCorrectService czTemperatureCorrectService;

    /**
     * 查询温度矫正系数列表
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:correct:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzTemperatureCorrect czTemperatureCorrect)
    {
        startPage();
        List<CzTemperatureCorrect> list = czTemperatureCorrectService.selectCzTemperatureCorrectList(czTemperatureCorrect);
        return getDataTable(list);
    }

    /**
     * 导出温度矫正系数列表
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:correct:export')")
    @Log(title = "温度矫正系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzTemperatureCorrect czTemperatureCorrect)
    {
        List<CzTemperatureCorrect> list = czTemperatureCorrectService.selectCzTemperatureCorrectList(czTemperatureCorrect);
        ExcelUtil<CzTemperatureCorrect> util = new ExcelUtil<CzTemperatureCorrect>(CzTemperatureCorrect.class);
        util.exportExcel(response, list, "温度矫正系数数据");
    }

    /**
     * 获取温度矫正系数详细信息
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:correct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(czTemperatureCorrectService.selectCzTemperatureCorrectById(id));
    }

    @GetMapping(value = "/getTempCorrectByCode/{code}")
    public AjaxResult getTempCorrectByCode(@PathVariable("code") String  code)
    {
        return AjaxResult.success(czTemperatureCorrectService.getTempCorrectByCode(code));
    }

    /**
     * 新增温度矫正系数
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:correct:add')")
    @Log(title = "温度矫正系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzTemperatureCorrect czTemperatureCorrect)
    {
        return toAjax(czTemperatureCorrectService.insertCzTemperatureCorrect(czTemperatureCorrect));
    }

    /**
     * 修改温度矫正系数
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:correct:edit')")
    @Log(title = "温度矫正系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzTemperatureCorrect czTemperatureCorrect)
    {
        int count = czTemperatureCorrectService.updateCzTemperatureCorrect(czTemperatureCorrect);
        czTemperatureCorrectService.checkTemperatureCorrect();
        return toAjax(count);
    }

    /**
     * 删除温度矫正系数
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:correct:remove')")
    @Log(title = "温度矫正系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(czTemperatureCorrectService.deleteCzTemperatureCorrectByIds(ids));
    }
}
